{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "authorship_tag": "ABX9TyP+8/ZEPwig1ZqZ5uKP0gaT",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/LC1332/Haruhi-2-Dev/blob/main/notebook/test_pipinstall.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "PnD9adsyh5j4"
      },
      "outputs": [],
      "source": [
        "!pip install chatharuhi\n",
        "!pip -q install transformers openai tiktoken langchain chromadb"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import os\n",
        "os.environ[\"OPENAI_API_KEY\"] = \"sk-wWxiiT0XwYDDzzNG4N\"\n"
      ],
      "metadata": {
        "id": "hhvvhg11ifIv"
      },
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "!wget -q https://github.com/LC1332/Haruhi-2-Dev/raw/main/data/characters/haruhi/haruhi.zip"
      ],
      "metadata": {
        "id": "YG9tCntuismv"
      },
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "!unzip -q haruhi.zip -d /content/new_output"
      ],
      "metadata": {
        "id": "kdEtvFQfi2Qt"
      },
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "from chatharuhi import ChatHaruhi\n",
        "\n",
        "db_folder = '/content/new_output/content/haruhi'\n",
        "system_prompt = '/content/new_output/content/system_prompt.txt'\n",
        "\n",
        "chatbot = ChatHaruhi( system_prompt = system_prompt,\\\n",
        "                      llm = 'openai' ,\\\n",
        "                      story_db = db_folder,\\\n",
        "                      verbose = True)"
      ],
      "metadata": {
        "id": "H9FlS3Lii4j1"
      },
      "execution_count": 6,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "response = chatbot.chat(role='阿虚', text = 'Haruhi, 你好啊')"
      ],
      "metadata": {
        "id": "fJgDUxWOobIY"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "print(response)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "e8XZ1CaLpY-D",
        "outputId": "f3d6e909-716b-4cc5-b1f7-2694c9bad80a"
      },
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "春日:「哦，你终于注意到我了吗？有什么事吗？」\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "response = chatbot.chat(role='阿虚', text = 'Haruhi, 你在干什么')"
      ],
      "metadata": {
        "id": "Y2JgHnh4pi4T"
      },
      "execution_count": 9,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "print(response)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "KGKwvp1kpvic",
        "outputId": "97e2954b-11d5-4715-e196-395c85899f5b"
      },
      "execution_count": 10,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "春日:「我正在思考下一个SOS团的活动呢，你有什么好的建议吗？」\n"
          ]
        }
      ]
    }
  ]
}